package com.daka.service.impl;

import com.daka.dao.BaseAddressMapper;
import com.daka.entity.BaseAddress;
import com.daka.service.BaseAddressService;
import com.daka.vo.request.BaseAddressRequestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yangx
 * CreateTime: 2016/9/27 16:14
 */
@Service("baseAddressService")
@SuppressWarnings("unused")
public class BaseAddressServiceImpl implements BaseAddressService {

    @Autowired
    private BaseAddressMapper baseAddressMapper;

    @Override
    public int insert(BaseAddress po) {
        return baseAddressMapper.insert(po);
    }

    @Override
    public int update(BaseAddress po) {
        return baseAddressMapper.updateByPrimaryKeySelective(po);
    }

    @Override
    public BaseAddress selectById(Long id) {
        return baseAddressMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<BaseAddress> selectAll() {
        return baseAddressMapper.selectAll();
    }

    @Override
    public List<BaseAddress> selectFirst() {
        return baseAddressMapper.selectFirst();
    }

    @Override
    public List<BaseAddress> selectSecond() {
        return baseAddressMapper.selectSecond();
    }

    @Override
    public List<BaseAddress> selectThird() {
        return baseAddressMapper.selectThird();
    }


    @Override
    public List<BaseAddress> selectAddressByConditions(BaseAddressRequestVo po) {
        po.setPageSize(10);
        if(po.getPageNo()==null){
            po.setPageNo(0);
        }else {
            po.setPageNo(10*po.getPageNo());
        }
        return baseAddressMapper.selectAddressByConditions(po);
    }

    @Override
    public int selectAddressByConditionsCount(BaseAddressRequestVo po) {
        return  baseAddressMapper.selectAddressByConditionsCount(po);
    }
}
